<?php
//extract student icampus from team data.

header('Content-type: application/json');
$sDatabaseName = "courses";
$sUser = "root";
$sPassword="quang6van21";
$sServer="localhost";
$sTableName="2014_w_la";
$sGroupName="sheet2";

$sqlConn= new mysqli($sServer,$sUser,$sPassword,$sDatabaseName);

$sqlQuery = "SELECT * FROM `".$sGroupName."`";

$sqlResult=$sqlConn->query($sqlQuery);
while ($row=$sqlResult->fetch_array(MYSQLI_NUM))
{
	$tmpStudentInfo=$row[0];
	$tmpStudentNumber=substr($tmpStudentInfo,-11,10);
	$tmpIcampus=substr($tmpStudentInfo,0,-12);
	
	//Update Records
	$sqlQuery="UPDATE `".$sTableName."` SET `icampus`='".$tmpIcampus."',`team`=".$row[2]." WHERE `student_number`=".$tmpStudentNumber;
	$sqlConn->query($sqlQuery);
}
$sqlConn->close();
?>